package com.minelx.statementsplus.cha.webauto;

import com.minelx.landisk.filesystem.core.File;
import com.minelx.statementsplus.cha.core.*;

// FIXME 2021/8/11  wait for me!!!     test
public class ChaPageSession implements IChaSession {
	private final ChaPageFactory chaPageFactory;

	public ChaPageSession(ChaPageFactory chaPageFactory) {
		this.chaPageFactory = chaPageFactory;
	}

	@Override
	public ExplainResponse explain(String majorSql) {
		try (ChaPage chaPage = chaPageFactory.createChaPage()) {
			return new ExplainResponse(chaPage.explain(majorSql), chaPage.tips());
		}
	}

	@Override
	public IChaTask createTask(TaskCommitment convertedCommitment, File destination) {
		return new SingleTask(chaPageFactory, convertedCommitment, destination);
	}
}
